package com.ibeeking.found.msg.rest.controller.v1;

import com.ibeeking.found.msg.rest.service.IWxMpFansService;
import com.ibeeking.found.msg.service.common.param.WxMpFansParam;
import com.ibeeking.found.msg.service.common.query.WxMpFansPageQuery;
import com.ibeeking.found.msg.service.common.vo.WxMpFansPageVO;
import com.ibeeking.found.msg.service.common.vo.WxMpFansVO;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

/**
 * @ClassName MpFansController控制器
 * @Description
 * @Author ibeeking
 * @Date 2020-12-30 14:12
 **/
@RestController
@RequestMapping("/b/wxMp/fans/v1")
public class WxMpFansController {

    @Resource
    private IWxMpFansService mpFansServiceImpl;

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "导出粉丝数据")
    @PostMapping(value = "/export")
    public Boolean export(@RequestBody WxMpFansPageQuery wxMpFansPageQuery) {
        return mpFansServiceImpl.export(wxMpFansPageQuery);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "粉丝分页列表查询")
    @PostMapping(value = "/pageList")
    public Page<WxMpFansPageVO> pageList(@RequestBody @Validated WxMpFansPageQuery wxMpFansPageQuery) {
        return mpFansServiceImpl.pageList(wxMpFansPageQuery);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "同步粉丝数据")
    @PostMapping(value = "/syncFansFromWx/{appId}")
    public Boolean syncFansFromWx(@PathVariable("appId") @NotNull(message = "公众号appid不能为空") String appId) {
        return mpFansServiceImpl.syncFansFromWx(appId);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改粉丝信息")
    @PostMapping(value = "/modify")
    public Boolean modify(@RequestBody @Validated WxMpFansParam param) {
        return mpFansServiceImpl.modify(param);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查看粉丝信息")
    @PostMapping(value = "/view/{appId}/{id}")
    public WxMpFansVO view(@PathVariable("appId") @NotNull(message = "公众号id不能为空") String appId, @NotNull(message = "id不能为空") @PathVariable("id") Long id) {
        return mpFansServiceImpl.view(appId, id);
    }
}
